package 环形链表II;

public class Test {
    public static void main(String[] args) {

        Solution solution = new Solution();

        ListNode l7 = new ListNode(-1, null);
        ListNode l6 = new ListNode(0, l7);
        ListNode l5 = new ListNode(1, l6);
        ListNode l4 = new ListNode(2, l5);
        ListNode l3 = new ListNode(3, l4);
        ListNode l2 = new ListNode(4, l3);
        ListNode l1 = new ListNode(5, l2);
        ListNode head = new ListNode(6, l1);
        l7.next = l6;

//        printM(head);

        ListNode result = solution.detectCycle(head);
        System.out.println(result.val);
//        printM(result);
    }

    public static void printM(ListNode head){
        ListNode p = new ListNode();
        p = head;
        while (p != null){
            System.out.print(p.val + " ");
            p = p.next;
        }
        System.out.println();
    }
}
